﻿using NAnt.SVN.Tasks.Constants;
using NAnt.Core.Attributes;
using NAnt.SVN.Attributes;

namespace NAnt.SVN.Tasks
{
    /// <summary>
    /// Superclass of the propset command to set keywords on files
    /// You can run this tasc with the svneolstyles tag in NAnt.
    /// $Id$
    /// </summary>
    [TaskName("svneolstyles")]
    public sealed class EOLStyles : PropSet
    {
        #region Private Fields

        private string value = string.Empty;

        #endregion

        /// <summary>
        /// The property is fixed here: keywords
        /// </summary>
        public override string Property
        {
            get
            {
                return SVNProperties.EOLSTYLE;
            }

        }

        /// <summary>
        /// The property value
        /// </summary>
        [TaskAttribute("value", Required = false)]
        [EOLStyleValidator()]
        public override string Value
        {
            get
            {
                SVNEolStyle eolstyles = new SVNEolStyle();
                if (string.IsNullOrEmpty(value))
                    value = SVNEolStyle.NATIVE;
                else
                    eolstyles.CorrectCasing(ref value);
                return value;
            }
            set
            {
                this.value = value;
            }
        }
    }
}
